<template>
  <div v-if="resumeList.length > 0" class="resume-list-section">
    <h3>简历列表</h3>
    <el-table :data="resumeList" style="width: 100%">
      <el-table-column prop="resumeNumber" label="简历编号"></el-table-column>
      <el-table-column prop="resumeName" label="简历名称"></el-table-column>
      <el-table-column prop="createdDate" label="创建时间">
        <template #default="scope">
          {{ new Date(scope.row.createdDate).toLocaleString() }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default="scope">
          <el-button type="primary" size="small" @click="handleSelect(scope.row)">选择</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup lang="ts">
import { defineProps, defineEmits } from 'vue'

interface ResumeItem {
  resumeNumber: string
  resumeName: string
  createdDate: string
}

const props = defineProps<{
  resumeList: ResumeItem[]
  lang: number
}>()

const emit = defineEmits<{
  select: [resume: ResumeItem & { lang: number }]
}>()

const handleSelect = (resume: ResumeItem) => {
  emit('select', { ...resume, lang: props.lang })
}
</script>

<style scoped>
.resume-list-section {
  margin-top: 20px;
}
</style>